package aden.Generic;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;



public class Gen2DView extends SurfaceView implements SurfaceHolder.Callback, OnTouchListener
{
    protected GenMain mMain;
    public GenMain GetMain() {return mMain;}
    
    public Gen2DView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public boolean Init(GenMain inMain)
    {
        mMain = inMain;
        mTool = null;
        return true;
    }
    
    public GenViewTool mTool;
    
    public GenViewTool GetTool() {return mTool;}
    
    public boolean PushTool(GenViewTool inTool)
    {
    	mTool = inTool;
    	return true;
    }
    
    @Override
    public boolean onTouch(View v, MotionEvent inEvent)
    {
        if (mTool != null)
        {
            if (inEvent.getAction() == inEvent.ACTION_DOWN)
            {
                return mTool.OnTouchDown(inEvent.getX(),inEvent.getY());        
            }
            else if (inEvent.getAction() == inEvent.ACTION_UP)
            {
            	return mTool.OnTouchUp(inEvent.getX(),inEvent.getY());        
            }
            else if (inEvent.getAction() == inEvent.ACTION_MOVE)
            {
            	return mTool.OnMove(inEvent.getX(),inEvent.getY()); 
            }
        }
        return true;
    }
    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width,
            int height)
    {
        // TODO Auto-generated method stub
        
    }
    @Override
    public void surfaceCreated(SurfaceHolder holder)
    {
        // TODO Auto-generated method stub
        
    }
    @Override
    public void surfaceDestroyed(SurfaceHolder holder)
    {
        // TODO Auto-generated method stub
        
    }
    
    public void Pan(float inPosX,float inPosY)
    {
        
    }
    
    public void Zoom(float inPosX1,float inPosY1,float inPosX2,float inPosY2)
    {
    	
    }

    public int GetWorldX(float inX,
            float inY)
    {
    	return 0;
    }
    public int GetWorldY(float inX,
            float inY)
    {
    	return 0;
    }


}